#include <iostream>
#include <cmath>
#include <string>

#include "conv.cpp"

using namespace std;

double input;

void choice();
double getInput();
void restart();


int main()
{
    cout << "=========================================" << endl;
    cout << "  " << "ConvertIt v1.0 BETA" << endl;
    cout << "           " << "by Markus (mafaer@gmail.com)" << endl;
    cout << "=========================================" << endl;
    cout << "\n" << endl;
    
    cout << "\t" << "Conversion Menu:" << endl;
    cout << "\t" << "   1. Celsius to Fahrenheit" << endl;
    cout << "\t" << "   2. Fahrenheit to Celsius" << endl;
    
    choice();
                            
    system("pause");
    return 0;
}

// Choice og Restart
void choice()
{
     string choice;
     cout << "\t" << "Conversion #: ";
     cin >> choice;
     cout << endl;
     if (choice == "1")
     {
        getInput();
        double ans = C2F(input);
        cout << input << " Celsius = " << ans << " Fahrenheit.";
        cout << endl;
     }
     else if (choice == "2")
     {
          getInput();
          double ans = F2C(input);
          cout << input << " Fahrenheit = " << ans << " Celsius.";       
          cout << endl;
     } else {
            cout << "ERROR: Undefined conversion." << endl;
                 }
    
    cout << "===================================" << endl;
    
    restart();
}

double getInput()
{
       cout << "Enter number: ";
       cin >> input;
       cout << endl;
       return input;
}

void restart()
{
     string choice2;
     cout << "\n\t" << "New conversion? (y/n) ";
     cin >> choice2;
     cout << endl;
     if (choice2 == "y")
     {
        choice();
     } else {
           cout << "\nBye bye.\n" << endl;
                }
}



